
import 'package:flutter_fitness/model/entity/record.dart';
import 'package:flutter_fitness/model/entity/user.dart';
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';

import '../../const.dart';

const String columnId = "id";

class DBHelper {

  static DBHelper instance = DBHelper._internal();
  DBHelper._internal();

  Future<Database> open() async {
    final databasePath = await getDatabasesPath();
    final path = join(databasePath, DB_NAME);
    return await openDatabase(path, version: DB_VERSION,
        onCreate: (Database database, int version) async {
          await database.execute('''
            create table $tableRecord ( 
              $columnId integer primary key autoincrement, 
              $columnUserId integer not null,
              $columnWeight double not null,
              $columnIsRead boolean not null,
              $columnStep int not null,
              $columnIsPray boolean not null,
              $columnYear int not null,
              $columnMonth int not null,
              $columnDay int not null)''');
          await database.execute('''
            create table $tableUser ( 
              $columnId integer primary key autoincrement, 
              $columnUsername text not null)
          ''');
        });
  }

}